
var images = document.getElementsByTagName( 'img' );
var imagesUrl = new Array();
var selectedText = window.getSelection().toString();

//extracting html selection
var fragment = document.getSelection().getRangeAt().cloneContents();
var p = document.createElement('p');
p.appendChild(fragment);
var htmlSelection = p.innerHTML;


for( var index = 0, picture, scale, pOriginalWidth, pOriginalHeight, pWidth, pHeight; index < images.length; index++ ) {
		if( images[index].width * images[index].height > 3000 ) {
			imagesUrl.push({ "src": images[index].src, "width": images[index].width, "height": images[index].height }); }
}
	
if( imagesUrl.length > 0 || selectedText )
	chrome.extension.sendRequest({ "validation": "page-script", "imagesArray": imagesUrl, "selectedText": selectedText,"htmlSelection": htmlSelection });
